<?php

/*
CREATE TABLE IF NOT EXISTS `felhasznalo` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `azonosito` varchar(30) collate utf8_hungarian_ci NOT NULL,
  `jelszo` varchar(32) collate utf8_hungarian_ci NOT NULL,
  `email` varchar(50) collate utf8_hungarian_ci NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci AUTO_INCREMENT=2 ;


INSERT INTO `felhasznalo` (`azonosito`, `jelszo`, `email`) VALUES
('user1', '24c9e15e52afc47c225b757e7bee1f9d', 'user1@pelda.hu');

-- user1/user1
*/


class Felhasznalo_model extends CI_Model {
	
	public function __construct() {
		parent::__construct();
		$this->load->database();
	}
	
	public function letezik_e($azonosito) {
		$query = $this->db->get_where('felhasznalo', array('azonosito' => $azonosito));
		return ($query->num_rows() > 0);
	}
	
	public function beszur($azonosito, $jelszo, $email) {
		$query = $this->db->insert(
			'felhasznalo',
			array(
				'azonosito' => $user,
				'jelszo' => $password,
				'email' => $email,
			)
		);
		return $query ? $this->db->insert_id() : false;
	}
	
	public function torol($id) {
		return $this->db->delete(
			'felhasznalo',
			array(
				'id' => $id
			)
		);
	}
	
	public function felhasznalo($azonosito) {
		$query = $this->db->get_where('felhasznalo', array('azonosito' => $azonosito));
		return $query->row_array();
	}
}
